package com.hnxxxy.sysmgr.controller;

import com.hnxxxy.common.annotation.LogAnno;
import com.hnxxxy.sysmgr.pojo.Project;
import com.hnxxxy.sysmgr.pojo.Staff;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.security.Principal;
import java.util.Set;

/**
 * @author Json
 * @date 2020-25-16:31
 */
@Controller
@RequestMapping("sys")
public class SystemController {

    /**
     * 跳转到工作台
     * @return
     */
    @RequestMapping("toWorkTable")
    @LogAnno(description = "跳转到工作台")
    public String toWorkTable(){

        return "workTable";
    }

    /**
     * 跳转到菜单管理
     * @return
     */
    @RequestMapping("toMenuManager")
    @LogAnno(description = "跳转到菜单管理")
    public String toMenuManager(){

        return "sysmgr/menuManager";
    }

    /**
     * 跳转到用户管理
     * @return
     */
    @RequestMapping("toUserManager")
    @LogAnno(description = "跳转到用户管理")
    public String toUserManager(){

        return "sysmgr/userManager";
    }

    /**
     * 跳转到角色管理
     * @return
     */
    @RequestMapping("toRoleManager")
    @LogAnno(description = "跳转到角色管理")
    public String toRoleManager(){

        return "sysmgr/roleManager";
    }

    /**
     * 跳转到权限管理
     * @return
     */
    @RequestMapping("toPermissonManager")
    @LogAnno(description = "跳转到权限管理")
    public String toPermissonManager(){

        return "sysmgr/permissionManager";
    }

    @GetMapping("/toDictionaryManager")
    @LogAnno(description = "请求字典管理页面")
    public String findAllSysLog(){ return "/sysmgr/dictionaryManager"; }

    /**
     * 跳转到修改密码
     */
    @RequestMapping("toChangePwd")
    public String toChangePwd(){
        return "sysmgr/changePwd";
    }

    /**
     * 请求更改密码的当前用户的信息
     * @param model
     * @return
     */
    @RequestMapping("/changePwd")
    @LogAnno(description = "请求更改密码的当前用户的信息")
    public String changePwd(Model model){
        Subject subject = SecurityUtils.getSubject();
        Staff staff =(Staff) subject.getPrincipal();
        model.addAttribute("user",staff);
        return "sysmgr/changePwd";
    }

    /**
     * 跳转到系统日志页面
     * @return
     */
    @GetMapping("/toLogInfoManager")
    @LogAnno(description = "请求系统日志页面")
    public String logInfoManager(){ return "/sysmgr/logInfoManager"; }

}
